package method1reference;

import java.util.Arrays;

public class Demo2
{
    public static void main(String[] args) {
        Student students[] = new Student[6];
        students[0] = new Student("张三", 28, 180, '男');
        students[1] = new Student("李四", 39, 170, '女');
        students[2] = new Student("王五", 35, 169, '男');
        students[3] = new Student("赵六", 28, 190, '女');
        students[4] = new Student("孙七", 22, 178, '男');
        students[5] = new Student("周八", 23, 175, '女');

        //按年龄排序
        //先打印看看
        for(int i = 0; i < students.length;i++)
        {
            Student s = students[i];
            System.out.println(s);
        }
        System.out.println("=========================================");
//        Arrays.sort(students, (Student o1, Student o2) ->{
//        return o2.getAge() - o1.getAge();});

//        Arrays.sort(students, (o1,  o2) -> o2.getAge() - o1.getAge());
//        Arrays.sort(students, (o1,  o2) -> Student.compareByAge(o1,o2));
//        Arrays.sort(students, Student::compareByAge);
        Student t = new Student();

      //  Arrays.sort(students,(o1, o2) ->t.compareByHeight(o1,o2));
        Arrays.sort(students,t::compareByHeight);
        for(int i = 0; i < students.length;i++)
        {
            Student s = students[i];
            System.out.println(s);
        }

    }
}
